package com.yunhe.rentcars.commons.dto;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by Administrator on 2017/9/29 0029.
 */
public class Pageable<E> {
    private  int  total;  //总行数
    private List<E> rows;   //数据
    private int page = 1;  //当前页
    private int size = 15;  //每页大小
    private int pageCount;  //总页数
    private boolean first;  //是否首页
    private boolean last;   //是否尾页


    public int getTotal() {
        return total;
    }

    public void setTotal(int total) {
        this.total = total;
        this. pageCount = (total % size  == 0) ? total / size  : total / size + 1;
        this.first = (1 == page) ? true : false;
        this.last = (pageCount == page) ? true : false;
    }

    public boolean isFirst() {
        return first;
    }

    public boolean isLast() {
        return last;
    }

    public int getPageCount() {
        return pageCount;
    }

    public List<E> getRows() {
        return rows;
    }

    public void setRows(List<E> rows) {

        if(null == rows){
            this.rows = new ArrayList<>();
        }else{
            this.rows = rows;
        }
        /*this.rows = rows;*/
    }

    public int getPage() {
        return page;
    }

    public void setPage(int page) {
        this.page = page;
    }

    public void setPage(String page) {
        if(null != page) {
            this.page = Integer.valueOf(page);
        }
    }

    public int getSize() {
        return size;
    }

    public void setSize(int size) {
        this.size = size;
    }

    public void setSize(String size) {
        if(null != size) {
            this.size = Integer.valueOf(size);
        }

    }
}
